package bizlogic;

import java.util.ArrayList;

import model.UserDTO;
import exception.DAOSystemException;
import dao.DAOFactory;
import dao.UserDAO;

public class UserManager {
	private UserDAO userDAO;
	public UserManager() {
		userDAO = DAOFactory.loadInstance().getUserDAO();
	}

	@SuppressWarnings("finally")
	public UserDTO findUser(String id) throws DAOSystemException{
		UserDTO currentUser = new UserDTO();

			currentUser = userDAO.findUser(id);

			return currentUser;

		
	}
	
	@SuppressWarnings("finally")
	public UserDTO findByUsername(String username) throws DAOSystemException{
		UserDTO currentUser = new UserDTO();
			currentUser = userDAO.findUser(username);

			return currentUser;

	}
	
    @SuppressWarnings("finally")
	public ArrayList<UserDTO> findAllUser() throws DAOSystemException {
    	ArrayList<UserDTO> currentList = new ArrayList<UserDTO>();

			currentList = userDAO.findAllUser();

			return currentList;

    }
    
    public void insertUser(UserDTO user) throws DAOSystemException {

			userDAO.insertUser(user);

    }
    public void updateUser(UserDTO user) throws DAOSystemException {

			userDAO.updateUser(user);

    }
    public void deleteUser(UserDTO user) throws DAOSystemException {

			userDAO.deleteUser(user);

    }
}
